part of '../repository.dart';

const _kWebPurchasedSubscriptionActiveStatusValue = 'active';
const _kWebPurchasedSubscriptionExpiredStatusValue = 'expired';
const _kWebPurchasedSubscriptionRevokedStatusValue = 'revoked';

class _WebPurchasedSubscriptionStatusDto extends Equatable {
  const _WebPurchasedSubscriptionStatusDto._internal({
    required this.statusString,
  });

  final String statusString;

  @override
  List<Object?> get props {
    return [
      statusString,
    ];
  }

  factory _WebPurchasedSubscriptionStatusDto.fromString(String statusString) {
    return _WebPurchasedSubscriptionStatusDto._internal(
      statusString: statusString,
    );
  }

  WebPurchasedSubscriptionStatus toEntity() {
    if (statusString == _kWebPurchasedSubscriptionActiveStatusValue) {
      return WebPurchasedSubscriptionStatus.active;
    }

    if (statusString == _kWebPurchasedSubscriptionExpiredStatusValue) {
      return WebPurchasedSubscriptionStatus.expired;
    }

    if (statusString == _kWebPurchasedSubscriptionRevokedStatusValue) {
      return WebPurchasedSubscriptionStatus.revoked;
    }

    throw UnimplementedError();
  }
}
